package cn.jboa.service.impl;

import cn.jboa.dao.EmployeeDao;
import cn.jboa.entity.SysEmployee;
import cn.jboa.exception.JboaException;
import cn.jboa.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("employeeService")
public class EmployeeServiceImpl  implements EmployeeService {
    @Autowired
    @Qualifier("empDao")
    private EmployeeDao empDao;
    public SysEmployee login(SysEmployee emp) {
        SysEmployee employee = empDao.fineEmployeeBySN(emp.getSn());
        if (employee != null && employee.getPassword().equals(emp.getPassword())) {
            return employee;
        } else {
            throw new JboaException("无效的用户名或密码");
        }
    }

    public SysEmployee getManager(SysEmployee employee) {
        return empDao.getManager(employee);
    }

    public EmployeeDao getEmpDao() {
        return empDao;
    }

    public void setEmpDao(EmployeeDao empDao) {
        this.empDao = empDao;
    }
}
